package com.amado.course45mysql03.service.impl;

import java.util.List;

import com.amado.course45mysql03.dao.RoleDao;
import com.amado.course45mysql03.dao.RoleOptMappingDao;
import com.amado.course45mysql03.dao.impl.RoleDaoImpl;
import com.amado.course45mysql03.dao.impl.RoleOptMappingImpl;
import com.amado.course45mysql03.domain.Role;
import com.amado.course45mysql03.service.RoleService;
import com.amado.course45mysql03.vo.Page;

public class RoleServiceImpl implements RoleService {
	private RoleDao roleDao = new RoleDaoImpl();
	private RoleOptMappingDao roleOptMappingDao  =new RoleOptMappingImpl();

	@Override
	public boolean add(Role t) {
		if(t==null){
			return false;
		}
		//添加角色
		roleDao.add(t);
		//添加角色对应的权限中间表
		roleOptMappingDao.add(t.getOptList());
		return true;
	}

	@Override
	public boolean upadte(Role t) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean isExists(String roleCode) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean delete(String roleCode) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public Role getByCode(String roleCode) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Role> listAll() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Page<Role> listAll(Page<Role> page) {
		int count = roleDao.getCount();
		//设置有多少数据
		page.setCount(count);
		List<Role> roleList = roleDao.listAll(page);
		page.setList(roleList);
		return page;
	}

	@Override
	public Page listAllNo(Page page) {
		int count = roleDao.getCount();
		//设置有多少数据
		page.setCount(count);
		List roleList = roleDao.listAll(page);
		page.setList(roleList);
		return page;
	}
	

}
